//动态存储空间的申请与释放
#include <iostream>
using namespace std;
int* apply(int n)
{
	int *arr =new int [n];
	for(int i=0;i<n;i++)
        arr[i]=2*i+1;
	return arr;
}
void release(int *arr)
{
	delete [] arr;
}
int main()
{
	int n;
	cout<<"please input n:";
	cin >> n;
      	int *p;
    	p=apply(n);
    	for(int i=0;i<n;i++)
        	cout<<p[i]<<"  ";
	release(p);
	return 0;
}
/*
//请分析以下代码的错误原因
#include <iostream>
using namespace std;
int* apply(int n)
{
	int arr[n];
	for(int i=0;i<n;i++)
        arr[i]=2*i+1;
	return arr;
}

int main()
{
	int n;
	cout<<"please input n:";
	cin >> n;
    int *p;
    p=apply(n);
    for(int i=0;i<n;i++)
        cout<<p[i]<<"  ";
	return 0;
}
*/